import logger from '../../lib/Log4js';
import { IRouterContext } from 'koa-router';

/* eslint no-param-reassign: 0 */
let log4js = require('koa-log4');
export default function finalHandler() {
    return async (ctx: IRouterContext, next: any) => {
        try {
            await next();
        } catch (error) {
            console.error(error);
            ctx.body = error;
            ctx.status = 500;
        }
    };
}
